#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int T, m, n;
	cin >> T;
	while (T--) {
		cin >> n >> m;
		int ans = 0;
		while ((n > 1 && m) || (m > 1 && n)) {
			int a1 = n / 2, b1 = m;
			int a2 = n, b2 = m / 2;
			int ans1 = a1 <= b1 ? a1 : b1;
			int ans2 = a2 <= b2 ? a2 : b2;
			if (ans1 > ans2)
				n -= ans1 * 2, m -= ans1, ans += ans1;
			else if (ans1 < ans2)
				n -= ans2, m -= ans2 * 2, ans += ans2;
			else {
				int leN1 = n - ans1 * 2;
				int leM1 = m - ans1;
				int leN2 = n - ans2;
				int leM2 = m - ans2 * 2;
				if (leN1 + leM1 > leN2 + leM2)
					n = leN1, m = leM1;
				else
					n = leN2, m = leM2;
			}
		}
		cout << ans << endl;
	}
	return 0;
}
